﻿namespace com.oakwoodsys.ConsultantCareDao
{
    using System;

    using com.oakwoodsys.SharePoint;

    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Linq;

    using Context = ConsultantCareDataContext;

    public class DeletionDao : BaseDao
    {
        #region Fields

        public const string ListName = "cc_backgrounddeletion";

        #endregion Fields

        #region Constructors

        public DeletionDao( )
            : base( ListName )
        {
            CurrentWebUrl = SPContext.Current.Web.Url;
        }

        public DeletionDao( string currentWebUrl )
            : base( ListName )
        {
            CurrentWebUrl = currentWebUrl;
        }

        #endregion Constructors

        #region Methods

        public void Add( string area, Guid id )
        {
            using ( Context c = new Context( CurrentWebUrl ) )
            {
                EntityList<Item> l = c.GetList<Item>( ListTitle );
                Item v = new Item( );
                v.Title = string.Format( "{0}:{1}", area, id.ToString( ) );
                l.InsertOnSubmit( v );
                c.SubmitChanges( );
            }
        }

        #endregion Methods
    }
}